import request from './request.js'
//引入mock 的 axios 文件
import mockAjax from '@/api/mockAjax'
//封装请求，按需导出请求
export const reqCategoryList = () => request({ url: '/product/getBaseCategoryList', method: 'get' })
//封装请求api
export const getBannerList = () => mockAjax({ url: '/banner', method: 'get' })
//获取floor数据
export const getFloorList = () => mockAjax({ url: 'floor', method: 'get' })
//获取search 组件数据
//这个params参数至少是一个空对象
export const getSearchInfo = (params) =>
  request({
    url: '/list',
    method: 'post',
    data: params,
  })
//获取商品详情数据
export const getDetailInfo = (skuId) => {
  return request({ url: `/item/${skuId}`, method: 'get' })
}

//提交加入购物车数据
export const addToCartOfUpdate = (skuId, skuNum) => {
  return request({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })
}

//获取购物车数据
export const getshopCartList = () => {
  return request({ url: '/cart/cartList', method: 'get' })
}

//删除购物车数据
export const deleteShopCartInfo = (skuId) => {
  return request({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })
}

//修改购物车选中状态
export const shopCartChecked = (skuId, isChecked) => {
  return request({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })
}

//获取验证码
export const getCode = (phone) => {
  return request({ url: `/user/passport/sendCode/${phone}`, method: 'get' })
}

//注册接口
export const userRegister = (data) => {
  return request({ url: '/user/passport/register', method: 'post', data: data })
}

//登录接口
export const userLogin = (data) => {
  return request({ url: '/user/passport/login', method: 'post', data: data })
}
//获取用户数据
export const userInfo = () => {
  return request({ url: '/user/passport/auth/getUserInfo', method: 'get' })
}

//退出登录接口
export const userLogout = () => {
  return request({ url: '/user/passport/logout', method: 'get' })
}

//获取用户地址信息
export const getUserAddressInfo = () => {
  return request({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' })
}

//获取订单交易页信息
export const getUserTradeInfo = () => {
  return request({ url: '/order/auth/trade', method: 'get' })
}

//提交订单信息获取订单id
export const getOrderId = (tradeNo, data) => {
  return request({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, method: 'post', data: data })
}

//根据订单id获取订单信息
export const getOrderInfo = (orderId) => { return request({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' }) }

//根据订单id查询订单支付状态
export const getOrderStatus = (orderId) => { return request({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get' }) }

//获取订单列表
export const getOrderList = (page, limit) => { return request({ url: `/order/auth/${page}/${limit}`, method: 'get' }) }
